package com.godz.frontData.index;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.godz.mapper.indexPiMapper;
import com.godz.pojo.indexPi;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
/**
 * @author GodzIINeo2023
 传给Vue的数据,个人信息
 */
@RestController
public class piData {

    final
    indexPiMapper indexPiMapper;

    public piData(indexPiMapper indexPiMapper) {
        this.indexPiMapper = indexPiMapper;
    }

    /**查询个人信息*/
    @GetMapping("/index/get/indexPi")
    public List<indexPi> getPi(){
        return indexPiMapper.queryAllPi();
    }
    /**修改个人信息*/
    @PostMapping("/index/post/editPi")
    public String EditPi(@RequestBody indexPi pi){
        QueryWrapper<indexPi> wrapper = new QueryWrapper<>();
        wrapper.eq("id", 1);

        indexPi neoPi = new indexPi();
        neoPi.setPiName(pi.getPiName());
        neoPi.setPiPd(pi.getPiPd());
        neoPi.setPiSiFirst(pi.getPiSiFirst());
        neoPi.setPiSiSecond(pi.getPiSiSecond());

        indexPiMapper.update(neoPi, wrapper);
        return "Update OK";
    }
}
